import { isLogin } from "@/utils/auth";
import { Navigate, useLocation } from "react-router-dom";

interface AuthRouterProps {
  children: React.ReactNode;
}

export default function AuthRouter({ children }: AuthRouterProps) {
  const location = useLocation();
  console.log(location);
  if (!isLogin()) {
    return (
      <Navigate to={`/login?redirect=${location.pathname}${location.search}`} />
    );
  }
  return <>{children}</>;
}
